package com.chiyou.action;

import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpException;

import com.chiyou.common.utils.PropertiesUtils;
import com.chiyou.common.utils.RedisUtils;
import com.chiyou.service.FutureNo1MonitorService;
import com.chiyou.service.FutureNo1TradingService;
import com.okcoin.rest.future.IFutureRestApi;
import com.okcoin.rest.future.impl.FutureRestApiV1;

public class FutureNo1 {
	public Log log =  LogFactory.getLog(FutureNo1.class);
	public static void main(String[] args) throws HttpException, IOException {
		PropertiesUtils properUtils = new PropertiesUtils();
		String current_tard_price = properUtils.getInstance(System.getProperty("user.dir") + "/conf/conf.properties").getProperty("current_tard_price");
		String option_status = properUtils.getInstance(System.getProperty("user.dir") + "/conf/conf.properties").getProperty("option_status");
		String current_order_id = properUtils.getInstance(System.getProperty("user.dir") + "/conf/conf.properties").getProperty("current_order_id");
		String netwok_val = properUtils.getInstance(System.getProperty("user.dir") + "/conf/conf.properties").getProperty("netwok_val");

		RedisUtils.addValue("netwok_val", netwok_val);
		RedisUtils.addValue("current_tard_price", current_tard_price);
		RedisUtils.addValue("option_status", option_status);
		RedisUtils.addValue("current_order_id", current_order_id);

		final long timeInterval = 1000;
		FutureNo1TradingService futureNo1Service = new FutureNo1TradingService();
		FutureNo1MonitorService futureNo1MonitorService = new FutureNo1MonitorService();

		ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();

		service.scheduleAtFixedRate(futureNo1Service, 1, 3, TimeUnit.SECONDS);
		service.scheduleAtFixedRate(futureNo1MonitorService, 0, 2, TimeUnit.SECONDS);
	}

}
